package com.jic.product.impl;

import java.lang.Long;
import java.util.List;

import com.jic.product.entity.ProductGuarantee;
import com.jic.product.mapper.ProductGuaranteeMapper;
import com.jic.product.service.ProductGuaranteeService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 商品保障表
 * @author : 
 * @email : 
 * @since : 2020-01-10 07:03:01
 * @version : v1.0.0
 */
@Service
public class ProductGuaranteeServiceImpl implements ProductGuaranteeService{

    @Autowired
    private ProductGuaranteeMapper productGuaranteeMapper;

    @Override
    public long insert(ProductGuarantee productGuarantee) {
        long flag = productGuaranteeMapper.insert(productGuarantee);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return productGuaranteeMapper.delete(id);
    }

    @Override
    public long update(ProductGuarantee productGuarantee) {
        return productGuaranteeMapper.update(productGuarantee);
    }

    @Override
    public ProductGuarantee queryByPrimaryKey(Long id){
        return productGuaranteeMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<ProductGuarantee> query(ProductGuarantee productGuarantee){
        return productGuaranteeMapper.query(productGuarantee);
    }

    @Override
    public PageResult<ProductGuarantee> queryPage(ProductGuarantee productGuarantee, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<ProductGuarantee> list = productGuaranteeMapper.queryPage(startIndex, pageQuery.getLimit(), productGuarantee);
        long count = productGuaranteeMapper.queryPageCount(productGuarantee);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}